
from django.db import models
from datetime import datetime

class Channel(models.Model):
    name = models.CharField(max_length=200, default='', blank=False,verbose_name='名称')
    flag = models.CharField(verbose_name='标识', max_length=200,default="")

    def __str__(self):
        return self.name
    class Meta:
        verbose_name = verbose_name_plural = '栏目'
        ordering = ['name']
    def url(self):
        return '/base/member/show/%s' % self.id
    url = property(url)

class Article(models.Model):
    name = models.CharField(max_length=30,verbose_name='标题')
    content = models.TextField(verbose_name='内容')
    hitCount = models.IntegerField(verbose_name='点击',default=0)
    channel= models.ForeignKey(Channel, verbose_name='栏目',on_delete=models.PROTECT)
    flag = models.IntegerField(verbose_name='置顶', choices=((0, '置顶'), (1, '取消置顶')), default=0)
    publishDatetime = models.DateTimeField(verbose_name='发布时间', default=datetime.now)
    class Meta:
        verbose_name = verbose_name_plural = '校'
        ordering = ['name']

class Banner(models.Model):
    name = models.CharField(max_length=30,verbose_name='标题')
    link = models.CharField(max_length=100,verbose_name='链接')
    file = models.CharField(max_length=100,verbose_name='图片名称')

    class Meta:
        verbose_name = verbose_name_plural = '图集'
        ordering = ['-id']










